<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>暠雨</title>
    <link rel="stylesheet" href="__STATIC__/index/css/base.css">
    <link rel="stylesheet" href="__STATIC__/index/css/style.css">

    <link href="__STATIC__/admin/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/font-awesome.min.css"/>
    <script src="__STATIC__/admin/js/jquery-1.9.1.min.js"></script>
    <script src="__STATIC__/admin/assets/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="__STATIC__/admin/bootstrap-fileinput-master/css/fileinput.css"/>
    <script src="__STATIC__/admin/bootstrap-fileinput-master/js/fileinput.js"></script>
    <script src="__STATIC__/admin/bootstrap-fileinput-master/js/locales/zh.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="__STATIC__/admin/assets/layer/layer.js" type="text/javascript"></script>
</head>

<body>
<div class="head-box">
    <div class="head wrap">
        <div class="logo fl"><a href=""><img src="__STATIC__/index/images/logo.png"></a></div>
        <div class="head-right fr">
            <div class="head-a fr">
                {if condition='$user'}
                <div class="head-a1 fl"><a href=""><img src="__STATIC__/index/images/tb-a.png"></a></div>
                <div class="head-a1 fl"><a href=""><img src="__STATIC__/index/images/tb-b.png"></a></div>
                <div class="tbt fl"><img src="__UPLOAD__/user/{$user.image_thumb}" style="width: 30px;">
                    <div class="hgt-btm">
                        <a href="{:url('user/collection',['user_id'=>$user.user_id])}">我的主页</a>
                        <a href="">消息</a>
                        <a href="">我的关注</a>
                        <a href="{:url('user/account',['user_id'=>$user.user_id])}">帐号设置</a>
                        <a href="{:url('user/logon')}">退出</a>
                    </div>
                </div>

                {else}
                <div class="head-a1 fl"><a href=""><img src="__STATIC__/index/images/tb-a.png"></a></div>
                <div class="head-a1 fl"><a href=""><img src="__STATIC__/index/images/tb-b.png"></a></div>
                <div class="head-a3 fl"><a href="{:url('login/index')}">登录</a></div>
                <div class="head-a4 fl"><a href="{:url('login/login')}">注册</a></div>
                {/if}


            </div>
            <div class="clearfix"></div>
            <div class="nav fr">
                <ul>
                    <li><a href="{:url('index/index')}">首页</a></li>
                    <li><a href="{:url('question/article')}">文章</a>
                    </li>
                </ul>
            </div>
            <div class="clearfix"></div>
        </div>
    </div>
</div>

<div class="content">
    <div class="wrap">
        <div class="tsm-height"></div>
        <div class="account">
            <div class="account-title">账户设置</div>
            <form action="">
                <div class="tsm-box">
                    <div class="tsm-title">个人资料
                    </div>

                    <div class="tsm-a" style="display:block;">
                        <input type="hidden" name="user_id" value="{$user.user_id}" id="grid">
                        <div class="tsm-a1">
                            <div class="tsm-a2 fl">昵称：</div>
                            <div class="tsm-a3"><input type="text" name="user_name" class="tsm-text1" id="user_name"
                                                       value="{$user.user_name}"/></div>
                        </div>

                        <div class="tsm-a1">
                            <div class="tsm-a2 fl">性别：</div>
                            <div class="tsm-a4">
                                <input type="radio" checked="checked" name="gender" value="男" {if
                                       condition='$user.gender==1' }checked id="gender" {/if}>男
                                <span><input type="radio" name="gender" value="女" {if condition='$user.gender=0'
                                             }checked id="gender" {/if}/>女</span>
                            </div>
                        </div>
                        <div class="tsm-a1">
                            <div class="tsm-a2 fl">职业：</div>
                            <div class="tsm-a3"><input type="text" name="occupation" id="occupation" class="tsm-text1"
                                                       value="{$user.address}"></div>
                        </div>

                        <div class="tsm-a1">
                            <div class="tsm-a2 fl">所在城市：</div>
                            <div class="tsm-a3"><input type="text" name="address" id="address" class="tsm-text1"
                                                       value="{$user.address}"></div>
                        </div>

                        <div class="tsm-a1">
                            <div class="tsm-a2 fl">生日：</div>
                            <div class="tsm-a3"><input type="text" name="birthday" id="birthday" class="tsm-text1"
                                                       value="{$user.birthday}"></div>
                        </div>


                        <div class="tsm-a1">
                            <div class="tsm-a2 fl">简介：</div>
                            <div class="tsm-a5"><textarea class="tsm-area" id="brief"
                                                          name="brief">{$user.brief}</textarea></div>
                        </div>
                        <div id="xg-btn"><input type="button" class="tsm-btn" value="提交"></div>
                    </div>

                </div>
            </form>
            <form action="{:url('user/txImg',['user_id'=>$user.user_id])}" method="post">
                <div class="tsm-box">
                    <div class="tsm-title">头像修改
                    </div>

                    <div class="tsm-b">

                        <div class="tt-put fl">
                            <div role="tabpanel" class="tab-pane" id="img">
                                <input id="imgUpload" type="file" class="file-loading">
                                <input type="hidden" name="image" id="image" value="">
                                <input type="hidden" name="image_thumb" id="image_thumb" value="">
                            </div>

                        </div>
                        <div><input type="submit" class="tsm-btn" value="提交"></div>
                    </div>
                </div>
            </form>
            <div class="tsm-box">
                <div class="tsm-title">密码
                </div>
                <div class="tsm-a">
                    <input type="hidden" name="user_id" value="{$user.user_id}" id="pwdid">
                    <div class="tsm-a1">
                        <div class="tsm-a2 fl">当前密码：</div>
                        <div class="tsm-a3"><input type="text" name="now_pwd" id="now_pwd" class="tsm-text1"></div>
                    </div>

                    <div class="tsm-a1">
                        <div class="tsm-a2 fl">新密码：</div>
                        <div class="tsm-a3"><input type="text" name="user_pwd" id="user_pwd" class="tsm-text1">
                        </div>
                    </div>
                    <div class="tsm-a1">
                        <div class="tsm-a2 fl">确认密码：</div>
                        <div class="tsm-a3"><input type="text" name="confirm_pwd" id="confirm_pwd"
                                                   class="tsm-text1"></div>
                    </div>

                </div>
            </div>


            <div class="tsm-href" id="mmxg"><input type="button" class="tsm-btn" value="保存"></div>

        </div>

    </div>
</div>
</div>

<div class="footer">
    <div class="wrap">
        <div class="foot">
            <div class="foot-left fl">
                <a href="">关于我们</a>
                <a href="">加入我们</a>
                <a href="contact.html">联系我们</a>
                <a href="">媒体采访</a>
            </div>
            <div class="foot-c fl"><a href=""><img src="__STATIC__/index/images/foot-logo.jpg"></a></div>
            <div class="foot-right fr">
                <a href="">同城活动</a>
                <a href="">课程资讯</a>
                <a href="">最新发布</a>
                <a href="">热门文章</a>
            </div>
        </div>
    </div>
</div>
<script src="__STATIC__/index/js/Action.js"></script>

<script>
    $(".tsm-title").click(function () {
        $(this).toggleClass("tsm-t2").parent().siblings().find(".tsm-title").removeClass("tsm-t2"),
            $(this).next().slideToggle().parent().siblings().find(".tsm-a").slideUp()
    });
    $('#imgUpload').fileinput({
        language: 'zh',
        uploadUrl: '{:url("user/uploadImg")}',
        autoRelace: true,
        maxFileCount: 1,
        allowedFileExtensions: ["jpg", "png", "gif"],
        browseClass: "btn btn-primary",
        previeFileIcon: "<i class='glyphicon glyphicon-king'></i>"
    });
    $('#imgUpload').on('fileuploaded', function (e, data) {
        if (data.response.status > 0) {
            $('#image').val(data.response.path);
            $('#image_thumb').val(data.response.thumb);
        } else {
            alert(data.response.err);
        }
    });
    $("#xg-btn").on('click', function () {

        //记录错误次数
        var num = 0;
        //记录错误信息
        var str = "";
        var user_name = ($('#user_name').val());
        var gender = ($('#gender')).val();
        var address = ($('#address')).val();
        var birthday = ($('#birthday')).val();
        var brief = ($('#brief')).val();
        var id = ($('#grid')).val();
        var occupation=$('#occupation').val();
        if (user_name == "") {
            str += '昵称不能为空<br>';
            num++;
        }
        //num>0,就表明错误
        if (num > 0) {
            layer.msg(str, {
                title: '错误提示',
                icon: 2
            })
        }
        ;
        var data = {
            user_name: user_name,
            gender: gender,
            address: address,
            birthday: birthday,
            brief: brief,
            user_id: id,
            occupation:occupation
        };
        var url = "{:url('user/account')}";
        $.post(url, data, function (res) {
            if (res.status == 1) {
                layer.msg(res.msg, {
                    title: '提示',
                    icon: 6
                })
            } else {
                layer.msg(res.msg, {
                    title: '错误提示',
                    icon: 2
                })
            }
        }, 'json');
    });


        $("#mmxg").on('click', function () {
            //记录错误次数
            var num = 0;
            //记录错误信息
            var str = "";
            var now_pwd = ($('#now_pwd').val());
            var user_pwd = ($('#user_pwd').val());
            var confirm_pwd = ($('#confirm_pwd').val());
            var id = ($('#pwdid')).val();
            if (now_pwd == "") {
                str += '当前密码不能为空<br>';
                num++;
            }
            if (user_pwd == "") {
                str += '新密码不能为空<br>';
                num++;
            }
            if (confirm_pwd == "") {
                str += '确认密码不能为空<br>';
                num++;
            }
            //num>0,就表明错误
            if (num > 0) {
                layer.msg(str, {
                    title: '错误提示',
                    icon: 2
                })
            }
            ;
            var data = {
                user_id:id,
                now_pwd: now_pwd,
                user_pwd: user_pwd,
                confirm_pwd: confirm_pwd
            };
            var url = "{:url('user/pwdXg')}";
            $.post(url, data, function (res) {
                if (res.status == 1) {
                    layer.msg(res.msg, {
                        title: '提示',
                        icon: 6
                    })
                } else {
                    layer.msg(res.msg, {
                        title: '错误提示',
                        icon: 2
                    })
                }
            }, 'json');
        });
</script>


</body>
</html>
